#define _CRT_SECURE_NO_WARNINGS 1
#include "Heap.h"

int main()
{
	HP hp;
	HeapInit(&hp);

	HeapPush(&hp, 4);
	HeapPush(&hp, 18);
	HeapPush(&hp, 41);
	HeapPush(&hp, 62);
	HeapPush(&hp, 3);
	HeapPush(&hp, 5);
	HeapPush(&hp, 15);
	HeapPush(&hp, 45);
	HeapPush(&hp, 13);
	HeapPush(&hp, 22);
	HeapPush(&hp, 33);
	HeapPush(&hp, 55);
	HeapPush(&hp, 17);
	HeapPush(&hp, 95);

	int k = 0;
	scanf("%d", &k);

	while (!HeapEmpty(&hp) && k--)
	{
		printf("%d ", HeapTop(&hp));
		HeapPop(&hp);
	}
	printf("\n");

	return 0;
}